  var numTicks = 0;
    var secondsTil = 19839;
    
    var intervalid = startClock();

    function startClock() {
        return setInterval(tick, 1000);
    }
    
    function tick() {
        var seconds = secondsTil--;
        if (seconds < 0) {
            seconds = 0;
        }
        var hours = Math.floor(seconds / 3600);
        seconds -= hours * 3600;
        var minutes = Math.floor(seconds / 60);
        seconds -= minutes * 60;


        var StrTime = hours.toString();
        if(hours < 10)
        {
            StrTime = "0"+ StrTime;
        }
        document.getElementById("timeremh").innerHTML = StrTime;
        StrTime = minutes.toString();
        if(minutes < 10)
        {
            StrTime = "0"+ StrTime;
        }
         document.getElementById("timeremm").innerHTML = StrTime;
        
        StrTime = seconds.toString();
        if(seconds < 10)
        {
            StrTime = "0"+ StrTime;
        }
         document.getElementById("timerems").innerHTML = StrTime;        
        //document.getElementById("timeremh").innerHTML = hours >= 0 ? hours : 0;
        //document.getElementById("timeremm").innerHTML = minutes >= 0 ? minutes : 0;
        //document.getElementById("timerems").innerHTML = secondsStr;
        if (numTicks++ > 500 || secondsTil == 0) {
            if (window.location.href.lastIndexOf('?') > -1) {
                window.location.href = window.location.href;
                clearInterval(intervalid);
            } else {
                window.location.href = window.location.href;
                clearInterval(intervalid);
            }
        }
    }

    $(document).ready(function() {
        
        var registerShare = function(destino) {
            $.ajax({
                url: 'http://www.peixeurbano.com.br/ofertas/ResgistraCompartilhamento/94594/00000000-0000-0000-0000-000000000000/' + destino,
                async: false
            });
        };

   

        $("#compartilharEmail").colorbox({
            iframe: true, 
            width: 750, 
            height: 520,
            onOpen: function(){ registerShare("email"); }
        });

     
       
       $(".popup").click(function(){
             var id = $(this).attr("href");
             var height = $(this).attr("height");
             var width = $(this).attr("width");
             var url = "/ofertas/popup";
             window.open(url + "/" + id, "popup_" + id, "scrollbars=yes,width=" + width + ",height=" + height);
             return false;
        });

        function lightboxExit(){}

       
       
       function openEmailInviteLightbox() {
            $.colorbox({iframe:true, href: '/layers/convidarporemail?discountID=94594'});
            //$.prettyPhoto.open('/layers/convidarporemail?discountID=94594&iframe=true&width=750&height=520');
        }
        
        

    });

    
